package com.jsmtr.rms.controller.SystemLog;

import com.jsmtr.rms.entity.*;
import net.sf.json.JSONObject;

/**
 * @author: cyx
 * @description:
 * @date: Created in 2019/4/15 21:52
 * @modified by:
 */
public class SystemLogUtil {

    public static SystemLog fillLogRsultAndRemark(String flowName, SystemLog log){
        if (log.getRequesturl().indexOf("ChangeTelAction")>0) {
            JSONObject jsonObject = JSONObject.fromObject(log.getLogcontent());
            //DUserResume resume = (DUserResume) JSONObject.toBean(jsonObject, DUserResume.class);
            log.setLogresult("更新手机号");
        }else if (log.getRequesturl().indexOf("NextAction")>0) {
            JSONObject jsonObject = JSONObject.fromObject(log.getLogcontent());
            DUserResume resume = (DUserResume) JSONObject.toBean(jsonObject, DUserResume.class);
            log.setLogresult("流转至下一步");
        }else if (log.getRequesturl().indexOf("syncDuserResume")>0){
            JSONObject jsonObject = JSONObject.fromObject(log.getLogcontent());
            DUserResume resume = (DUserResume) JSONObject.toBean(jsonObject, DUserResume.class);
            log.setLogresult("简历同步");
        }else if (log.getRequesturl().indexOf("PublishResultAction")>0){
            JSONObject jsonObject = JSONObject.fromObject(log.getLogcontent());
            DUserResume resume = (DUserResume) JSONObject.toBean(jsonObject, DUserResume.class);
            log.setLogresult("发布操作");
        }else{
            if (flowName.equalsIgnoreCase("简历筛选")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DUserResume resume=(DUserResume)JSONObject.toBean(jsonObject, DUserResume.class);
                log.setLogresult(resume.getState());
                log.setLogremark(resume.getSxbz());
            }else if (flowName.equalsIgnoreCase("笔试")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DoBSUser resume=(DoBSUser)JSONObject.toBean(jsonObject, DoBSUser.class);
                log.setLogresult(resume.getResult());
                log.setLogremark(resume.getRemark());
            }else if (flowName.equalsIgnoreCase("面试")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DoMSUser resume=(DoMSUser)JSONObject.toBean(jsonObject, DoMSUser.class);
                log.setLogresult(resume.getResult());
                log.setLogremark(resume.getRemark());
            }else if (flowName.equalsIgnoreCase("资料审核")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DUserResume resume=(DUserResume)JSONObject.toBean(jsonObject, DUserResume.class);
                log.setLogresult(resume.getZlstate());
                log.setLogremark(resume.getZlremark());
            }else if (flowName.equalsIgnoreCase("笔试")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DoBSUser resume=(DoBSUser)JSONObject.toBean(jsonObject, DoBSUser.class);
                log.setLogresult(resume.getResult());
                log.setLogremark(resume.getRemark());
            }else if (flowName.equalsIgnoreCase("政审")||flowName.equalsIgnoreCase("背景调查")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DUserResume resume=(DUserResume)JSONObject.toBean(jsonObject, DUserResume.class);
                log.setLogresult(resume.getZsstate());
                log.setLogremark(resume.getZsremark());
            }else if (flowName.equalsIgnoreCase("实作")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DoOperationUser resume=(DoOperationUser)JSONObject.toBean(jsonObject, DoOperationUser.class);
                log.setLogresult(resume.getResult());
                log.setLogremark(resume.getBz());
            }else if (flowName.equalsIgnoreCase("体检")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DUserResume resume=(DUserResume)JSONObject.toBean(jsonObject, DUserResume.class);
                log.setLogresult(resume.getTjstate());
                log.setLogremark(resume.getTjremark());
            }else if (flowName.equalsIgnoreCase("签约")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DUserResume resume=(DUserResume)JSONObject.toBean(jsonObject, DUserResume.class);
                log.setLogresult(resume.getQystate());
                log.setLogremark(resume.getQyremark());
            }else if (flowName.equalsIgnoreCase("实习")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DUserResume resume=(DUserResume)JSONObject.toBean(jsonObject, DUserResume.class);
                log.setLogresult(resume.getSxstate());
                log.setLogremark(resume.getSxremark());
            }else if (flowName.equalsIgnoreCase("录用")){
                JSONObject jsonObject=JSONObject.fromObject(log.getLogcontent());
                DUserResume resume=(DUserResume)JSONObject.toBean(jsonObject, DUserResume.class);
                log.setLogresult(resume.getBdstate());
                log.setLogremark(resume.getBdremark());
            }
        }
        return  log;
    }

}
